<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
   <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
   <script type="text/javascript" src="js/pageToc.js"></script>
   <script type="text/javascript" src="js/sh/scripts/shCore.js"></script>
   <script type="text/javascript" src="js/sh/scripts/shBrushJScript.js"></script>
   <script type="text/javascript" src="js/sh/scripts/shBrushPhp.js"></script>
   <script type="text/javascript" src="js/sh/scripts/shBrushPlain.js"></script>
   <script type="text/javascript" src="js/sh/scripts/shBrushXml.js"></script>
   <link type="text/css" rel="stylesheet" href="js/sh/styles/shCore.css"/>
   <link type="text/css" rel="stylesheet" href="js/sh/styles/shThemeDefault.css"/>
   <script type="text/javascript">
   		SyntaxHighlighter.config.clipboardSwf = 'js/sh/scripts/clipboard.swf';
   		SyntaxHighlighter.all();
   </script>
   <title>Code Style Guide</title>
</head>
<body>

   <h1>Code Style Guide</h1>
   
   <p>The most important thing about a style guide is that it exists and is enforced. Consistency, even to a suboptimal standard, means that it is easy and simple to navigate a code base. Of course, we think this standard makes a lot of sense.</p>
   
   <div id="pageToc"></div>

   <div id="contentArea">

   <h2 class="section">Use The Flex Style Guide</h2>

   <p>In order to be consistent with most exiting ActionScript codebases, we use the <a href="http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions">Adobe Flex Coding Conventions.</a> These are the core of our style guide, and the rest of this document merely notes where we differ or expand on their guidelines.</p>

   <h2 class="section">Naming</h2>
   
   <p class="summary">This section defines how all elements in your code should be named, as well as some special cases for specific types of classes.</p>
   
   <b>Definitions</b>
   <ul class="definitionList">
   <li class="definition">Upper Camel Case: The first letter of every word, including the first, is capitalized.</li>
   <li class="definition">Lower Camel Case: The first letter of every word, with the exception of the first, is capitalized.</li>
   </ul>
   
   <b>Abbreviations</b>
   <p>Abbreviations should not be used. Extremely common abbreviations, such as min or max, are okay.</p>
   <b>Acronyms</b>
   <p>Acronyms are okay. If the acronym is treated like a word, and the first letter should be capitalized, capitalize every letter in the acronym, otherwise, leave all letters lowercase.</p>
   <b>Component Names</b>
   <p>All components should have the word 'Component' appended to their name.</p>
   <b>Event Names</b>
   <p>All events should have the word 'Event' appended to their name.</p>
   <b>Callback Names and Event Handlers</b>
   <p>The first word should always be 'on'.</p>
   
   <h3 class="section">Error Reporting</h3>
   
   <p class="summary">There are several different ways to indicate runtime problems with the execution of the engine. This section defines the situations in which these different methods should be used. Additionally, the errors should be dispatched at the highest possible level in the call stack. For instance, a lookup method should not report that it failed to find an object. Instead, it should return null, and leave the reporting up to the calling method.</p>
   
   <b>Log Messages</b>
   <p>These should be used to report general information about the state of the engine.</p>
   <b>Log Warnings</b>
   <p>These should be used to report problems that don't inhibit the engine's ability to run, but could potentially be a problem.</p>
   <b>Log Errors</b>
   <p>These should be used to report problems that could impact the ongoing stability of the engine.</p>
   <b>Exceptions</b>
   <p>These should be used in situations that cannot be recovered from.</p>
      
   <h3 class="section">Whitespace</h3>
   
   <ul>
   <li>All mathematical operators (+, -, =, etc) should be surrounded by spaces.</li>
   <li>Parentheses do not have spaces immediately inside of them (to the right of opening parentheses, to the left of closing parentheses).</li>
   <li>A space should not exist between a function name and the opening parentheses.</li>
   <li>A space should always follow a comma or semi-colon except at the end of lines.</li>
   <li>A blank line should always follow a closing brace or single line block.</li>
   <li>Blank lines should be used to logically group sections of code.</li>
   <li>Ridiculously long lines should be split onto multiple lines, with subsequent lines indented two extra levels.</li>
   </ul>
   
   <h3 class="section">Braces</h3>
   
   <ul>
   <li>A brace should always be the only character on its line.</li>
   <li>Opening and closing braces are at the same indent level as surrounding code, and each other.</li>
   <li>Every opening brace indents code by one level (3 spaces).</li>
   <li>One line blocks do not have braces.</li>
   <li>One line if statements with multiline else statements, or vice versa, do have braces.</li>
   </ul>
   
   <h3 class="section">Other</h3>
   
   <ul>
   <li>Numbers that can be non integers should always have a decimal, even it if is just '.0'.</li>
   <li>Use parentheses in complex operations even if order of operations doesn't require it.</li>
   <li>Prefer early out returns to nested if statements. Try to minimize indentation depth</li>
   <li>One statement per line, in every case.</li>
   </ul>
   
   <h3 class="section">Imports</h3>
   
   <ul>
   <li>Organize imports by library, with a blank line between libraries.</li>
   <li>Explicitly list imported objects, rather than using package.*</li>
   </ul>
   
   </div>
</body>
</html>
